package com.hs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hs.entity.dto.Notice;
import com.hs.entity.dto.User;
import com.hs.mapper.NoticeMapper;
import com.hs.mapper.UserMapper;
import com.hs.service.NoticeService;
import com.hs.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements NoticeService {

    @Resource
    private NoticeMapper noticeMapper;


    @Override
    public PageInfo<Notice> selectNoticeList(Integer pageNum, String keywords) {
        PageHelper.startPage(pageNum,3);

        QueryWrapper<Notice> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("create_time");
        if (keywords != null && !keywords.isEmpty()) {
            queryWrapper.like("title", keywords);  // 根据用户名进行模糊查询
        }

        List<Notice> noticeList = noticeMapper.selectList(queryWrapper);
        return new PageInfo<>(noticeList);
    }


}
